package com.sys.readdata;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@lombok.Data
@AllArgsConstructor
@NoArgsConstructor
public class Data{
    int len;
    @JsonProperty("data")
    public List<Leafs> data = new ArrayList<Leafs>();

    public List<Leafs> getData() {
        return data;
    }

    public void setData(List<Leafs> data) {
        this.data = data;
    }

    public void add(Leafs leafs) {
        data.add(leafs);
    }

    @Override
    public String toString() {
        return "" + data + "";
    }

}

@lombok.Data
@AllArgsConstructor
@NoArgsConstructor
class Leafs {
    int len;

    @JsonProperty("leafs")
    public List<Leaf> leafs = new ArrayList<Leaf>();

    public void add(Leaf left) {
        leafs.add(left);
    }
    public List<Leaf> getLeafs() {
        return leafs;
    }

    public void setLeafs(List<Leaf> leafs) {
        leafs = leafs;
    }
    @Override
    public String toString() {
        return "{\"leafs\" : " + leafs + "}";
    }

}

@lombok.Data
class Leaf {
    @JsonProperty("name")
    private String name;
    @JsonProperty("value")
    private String value;

    public Leaf(){}
    public Leaf(String n, String v) {
        this.name = n;
        this.value = v;
    }
    @Override
    public String toString() {
        return " {\"name\" : " + name + ", value : " + value + "}";
    }

}
